home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Resources / General / ProNET / src / utilities / pronet-page.c < prev    next >
C/C++ Source or Header  |  1996-11-30  |  2KB  |  84 lines

  1. /*
  2.     pronet-page.c
  3.  
  4. */
  5.  
  6. #include <string.h>
  7.  
  8. #include <exec/exec.h>
  9. #include <devices/pronet.h>
  10.  
  11. #include <proto/exec.h>
  12. #include <proto/alib.h>
  13.  
  14. char verstring[] = "$VER: pronet-page 37.0 (30.11.96)";
  15.  
  16. void __chkabort(void) {}    /* Disable CTRL-C handling */
  17.  
  18. static ULONG unit = 0;
  19. static struct PNRequest *pronetio;
  20. static struct MsgPort *pronetport, *pronetport2;
  21.  
  22. #define ACTION_PAGE 19941996
  23.  
  24. int main(ULONG argc, char *argv[])
  25. {
  26.     ULONG RC = 20;
  27.     BYTE pronetopen;
  28.     char string[260];
  29.  
  30.     if(argc==3)
  31.     {
  32.         unit = atoi(argv[1]);
  33.         strncpy(&string[4], argv[2], 255);
  34.         string[259] = '\0';
  35.         ((ULONG*)string)[0] = ACTION_PAGE;
  36.  
  37.         if(pronetport2 = CreateMsgPort())
  38.         {
  39.             if(pronetio = (struct PNRequest*)CreateIORequest(pronetport2,sizeof(struct PNRequest)))
  40.             {
  41.                 if(pronetport = CreateMsgPort())
  42.                 {
  43.                     pronetio->pnr_NetSourcePort = PNP_NEXTFREE;
  44.                     pronetio->pnr_MsgPort = pronetport;
  45.                     pronetio->pnr_Data = &string;
  46.             
  47.                     if(!(pronetopen = OpenDevice("pronet.device",unit,(struct IORequest*)pronetio,PNF_ERRORSTRING)))
  48.                     {
  49.                         pronetio->pnr_Request.io_Command = CMD_WRITE;
  50.                         pronetio->pnr_Data = &string;        
  51.                         pronetio->pnr_Length = 260;
  52.                         pronetio->pnr_NetDestPort = 0;
  53.                         DoIO((struct IORequest*)pronetio);
  54.     
  55.                         RC = 0;
  56.                         CloseDevice((struct IORequest*)pronetio);
  57.                     }
  58.                     else switch(pronetopen)
  59.                     {
  60.                         case PNDERR_UNIT_NOT_DEFINED:
  61.                             Printf("Unit %ld not defined.\n",unit);
  62.                             break;
  63.             
  64.                         case PNDERR_DRIVERTROUBLE:
  65.                             Printf("Driver trouble: %s\n",&string);
  66.                             break;
  67.             
  68.                         default:
  69.                             Printf("Couldn't open pronet.device.\n");
  70.                             break;
  71.                     }
  72.                     DeleteMsgPort(pronetport);
  73.                 }
  74.                 DeleteIORequest((struct IORequest*)pronetio);
  75.             }
  76.             DeleteMsgPort(pronetport2);
  77.         }
  78.     }
  79.     else
  80.         Printf("Usage: pronet-page {Unit} \"{Text}\", e.g.\n       pronet-page 0 \"Hello, world!\"\n");
  81.  
  82.     return(RC);
  83. }
  84.